package com.springcloud.consumercourse.myinterface;

import com.entity.Course;
import com.entity.ResponseResultSet;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * @author
 * @create 2020-11-10 17:00
 * OpenFeign接口
 */

//申明调用的是那个服务   fallback 通过实现接口的方式定义降级处理方法
@FeignClient(value = "com-springcloud-coursedata",fallback = CourseOpenFeignFallBack.class)
//统一前缀
//@RequestMapping("/course")
public interface CourseOpenFeignClient {

    @GetMapping("/course/{cid}")
    ResponseResultSet<Course> getOneCourse(@PathVariable("cid") Integer cid);

    @GetMapping("/course/courses")
    ResponseResultSet<List<Course>> getCourses();

    @PostMapping("/course/addcourse")
    ResponseResultSet addCourse(Course course);

    //超时测试
    @RequestMapping("/course/timeout")
    ResponseResultSet timeOut();

    //熔断器下高并发的测试
    @RequestMapping("/course/ok")
    ResponseResultSet Ok();

}
